<template>
  <div ref="chart" style="width: 100%; height: 400px;"></div>
</template>

<script>
import echarts from 'echarts'

export default {
  data () {
    return {
      saleDataList: {
        day: ['周一', '周二', '周三', '周四', '周五', '周六', '周七'],
        value: [150, 230, 224, 218, 135, 147, 260]
      }
    }
  },
  props: ['saleData'],
  mounted () {
    this.renderChart()
  },
  methods: {
    renderChart () {
      const chart = echarts.init(this.$refs.chart)
      chart.setOption({
        title: {
          top: '30',
          text: '销售统计表',
          left: 'center'
        },
        xAxis: {
          type: 'category',
          data: this.saleData.day
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: this.saleData.value,
            type: 'line'
          }
        ]
      })
    }
  }
}
</script>
